package com.hd.auto;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Tmain {
	
	public static void main(String[] args) {
        InputStream ins = null;
        String[] cmd = new String[] { "cmd.exe", "/C", "ipconfig" };  // 命令
        try {
            Process process = Runtime.getRuntime().exec(cmd);
            ins = process.getInputStream();  // 获取执行cmd命令后的信息
            BufferedReader reader = new BufferedReader(new InputStreamReader(ins,"utf-8"));   
            String line = null;   
            while ((line = reader.readLine()) != null) {   
                System.out.println(line);  // 输出 
            } 
            int exitValue = process.waitFor();   
            System.out.println("返回值：" + exitValue);  
            process.getOutputStream().close();  // 不要忘记了一定要关
        } catch (Exception e) {
            e.printStackTrace();
        } 
    }

}
